import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'


Vue.config.productionTip = false

Vue.prototype.searchInjson = function(arr,activeName){
  let _i = 0, _content = ''
  for(let i = 0; i < arr.length; i++){
    if(arr[i].filename == activeName){
      _i = i
      _content = arr[i].content
      break;
    }
  }
  return {
    "_index":_i,
    "content":_content
  }
}
//判断文件是否重名
Vue.prototype.isFilenameInjson = function(arr, newfilename){
  let _is = true;
  for(let i = 0; i < arr.length; i++){
    if(arr[i].filename == newfilename){
      _is = false;
      break;
    }
  }
  return _is;
}
//下载文件
Vue.prototype.downloadFileInjson = function(filename, text) {
  let element = document.createElement('a');
  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
  element.setAttribute('download', filename);
  element.style.display = 'none';
  document.body.appendChild(element);
  element.click();
  document.body.removeChild(element);
}

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
